[Panel]
Title=Planisphere
HidenTimer=0
AlwaysActive=0
NumToolbar1=0
NumToolbar2=0
NumComponent=12
component_0="Group_4;;1"
component_1="	Event_0;0;Initialisation;"
component_2="	Memo_1;120"
component_3="	Button_3;https://en.wikipedia.org/wiki/Planisphere;0"
component_4="Group_1;Star chart;1"
component_5="	Memo_2;80"
component_6="	Button_1;Set chart;0"
component_7="Group_2;Horizon overlay;1"
component_8="	Memo_3;60"
component_9="	Button_2;Set overlay;0"
component_10="Group_5;Save and print;1"
component_11="	Memo_4;100"

[button_3]
s="begin"
"  OpenFile(button_3.caption);"
"end."


[button_1]
s=" var s,r,dt: string;"
"     i: integer;"
"     obslat:double;"
"     c: Tstringlist;"
""
" begin"
"    GetSL('STRL1',c);"
""
"    // Check observatory latitude"
"    c.clear;"
"    c.add('GETOBS');"
"    r:=cmd('',c);"
"    if copy(r,1,3)<>'OK!' then exit;"
"    i:=pos('LAT:',r);"
"    delete(r,1,i+3);"
"    i:=pos('d',r);"
"    obslat:=Strtofloat(trim(copy(r,1,i-1)));"
"    if abs(obslat)<20 then begin"
"       ShowMessage('Beware this kind of planisphere is only suited for a location with a latitude higher than 20°');"
"       exit;"
"    end;"
""
"    // create planisphere chart"
"    c.clear;"
"    c.add('SELECTCHART');"
"    c.add('Planisphere_Chart');"
"    r:=cmd('',c);"
""
"    if r <> 'OK!' then begin"
"      c.clear;"
"      c.add('NEWCHART');"
"      c.add('Planisphere_Chart');"
"      r:=cmd('',c);"
"    end;"
""
"    // resize to square"
"    GetI('CLIENTHEIGHT',i);"
"    i:=i-30;"
"    if i<200 then i:=200;"
"    s:=IntToStr(i);"
"    c.clear;"
"    c.add('RESIZE');"
"    c.add(s);"
"    c.add(s);"
"    r:=cmd('Planisphere_Chart',c);"
""
"    // force good options for a planisphere"
""
"    c.clear;"
"    c.add('SETPROJ');"
"    c.add('EQUAT');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETFOV');"
"    c.add('310.0');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETFOVPROJECTION');"
"    c.add('8');"
"    c.add('ARC');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETFOVPROJECTION');"
"    c.add('9');"
"    c.add('ARC');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETFOVPROJECTION');"
"    c.add('10');"
"    c.add('ARC');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETEQGRID');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETGRID');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('TRACKTELESCOPE');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('PLANISPHEREDATE');"
"    c.add('ON');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETRA');"
"    c.add('00.00');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    c.clear;"
"    c.add('SETDEC');"
"    if obslat>0 then"
"      c.add('90.00')"
"    else"
"      c.add('-90.00');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    // Set fixed time"
"    c.clear;"
"    c.add('GETDATE');"
"    dt:=cmd('Planisphere_Chart',c);"
"    if copy(dt,1,3)='OK!' then begin"
"      delete(dt,1,4);"
"      c.clear;"
"      c.add('SETDATE');"
"      c.add(dt)"
"      r:=cmd('Planisphere_Chart',c);"
"    end;"
""
"    c.clear;"
"    c.add('REDRAW');"
"    r:=cmd('Planisphere_Chart',c);"
""
"    if MenuShowPlanets.checked then MenuShowPlanets.click;"
"    if MenuShowAsteroids.checked then MenuShowAsteroids.click;"
"    if MenuShowComets.checked then MenuShowComets.click;"
"    if MenuChartInfo.checked then MenuChartInfo.click;"
"    if MenuChartLegend.checked then MenuChartLegend.click;"
"    if MenuShowCompass.checked then MenuShowCompass.click;"
""
"     c.clear;"
"  end."


[button_2]
s=" var s,r,dt: string;"
"     i: integer;"
"     st,hi,mi,si,hh,obslat: double;"
"     c: Tstringlist;"
" begin"
"    GetSL('STRL1',c);"
""
"    // Check observatory latitude"
"    c.clear;"
"    c.add('GETOBS');"
"    r:=cmd('',c);"
"    if copy(r,1,3)<>'OK!' then exit;"
"    i:=pos('LAT:',r);"
"    delete(r,1,i+3);"
"    i:=pos('d',r);"
"    obslat:=Strtofloat(trim(copy(r,1,i-1)));"
"    if abs(obslat)<20 then begin"
"       ShowMessage('Beware this kind of planisphere is only suited for a location with a latitude higher than 20°');"
"       exit;"
"    end;"
""
"    // Create planisphere overlay"
"    c.clear;"
"    c.add('SELECTCHART');"
"    c.add('Planisphere_Overlay');"
"    r:=cmd('',c);"
""
"    if r <> 'OK!' then begin"
"      c.clear;"
"      c.add('NEWCHART');"
"      c.add('Planisphere_Overlay');"
"      r:=cmd('',c);"
"    end;"
""
"    // Resize to square"
"    GetI('CLIENTHEIGHT',i);"
"    i:=i-30;"
"    if i<200 then i:=200;"
"    s:=IntToStr(i);"
"    c.clear;"
"    c.add('RESIZE');"
"    c.add(s);"
"    c.add(s);"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    // Set overlay options"
""
"    if MenuShowLabels.checked then MenuShowLabels.click;"
"    if MenuShowMilkyWay.checked then MenuShowMilkyWay.click;"
"    if MenuShowPictures.checked then MenuShowPictures.click;"
"    if MenuChartInfo.checked then MenuChartInfo.click;"
"    if MenuChartLegend.checked then MenuChartLegend.click;"
"    if MenuShowStars.checked then MenuShowStars.click;"
"    if MenuShowNebulae.checked then MenuShowNebulae.click;"
"    if MenuShowLines.checked then MenuShowLines.click;"
"    if MenuShowPlanets.checked then MenuShowPlanets.click;"
"    if MenuShowAsteroids.checked then MenuShowAsteroids.click;"
"    if MenuShowComets.checked then MenuShowComets.click;"
"    if MenuShowCompass.checked then MenuShowCompass.click;"
""
"    c.clear;"
"    c.add('SETPROJ');"
"    c.add('EQUAT');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETFOVPROJECTION');"
"    c.add('8');"
"    c.add('ARC');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETFOVPROJECTION');"
"    c.add('9');"
"    c.add('ARC');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETFOVPROJECTION');"
"    c.add('10');"
"    c.add('ARC');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETFOV');"
"    c.add('310.0');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETEQGRID');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETGRID');"
"    c.add('ON');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SHOWALWAYSMERIDIAN');"
"    c.add('ON');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SHOWONLYMERIDIAN');"
"    c.add('ON');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETGRIDNUM');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETCONSTLINE');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETCONSTBOUNDARY');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('MARKCENTER');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('TRACKTELESCOPE');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
""
"    c.clear;"
"    c.add('SHOWPICTURE');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SHOWBGIMAGE');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('PLANISPHERETIME');"
"    c.add('ON');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('PLANISPHEREDATE');"
"    c.add('OFF');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETRA');"
"    c.add('00.00');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('SETDEC');"
"    if obslat>0 then"
"      c.add('90.00')"
"    else"
"      c.add('-90.00');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"    c.add('REDRAW');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    // Set time at 0H sidereal"
"    c.clear;"
"    c.add('GETDATE');"
"    dt:=cmd('Planisphere_Overlay',c);"
"    if copy(dt,1,3)='OK!' then begin"
"      delete(dt,1,4);"
"      i:=pos('T',dt);"
"      hi:=StrtoFloat(trim(copy(dt,i+1,2)));"
"      mi:=StrtoFloat(trim(copy(dt,i+4,2)));"
"      si:=StrtoFloat(trim(copy(dt,i+7,2)));"
"      dt:=copy(dt,1,i);"
"      hh:=hi+mi/60+si/3600;"
"      getD('SIDEREALTIME',st);"
"      st:=rad2deg*st/15;"
"      hh:=hh+(24-st)/1.00273790935;"
"      if hh>24 then hh:=hh-24;"
"      if hh<0 then hh:=hh+24;"
"      hi:=trunc(hh);"
"      hh:=60*(hh-hi);"
"      mi:=trunc(hh);"
"      si:=trunc(60*(hh-mi));"
"      dt:=dt+inttostr(trunc(hi))+':'+inttostr(trunc(mi))+':'+inttostr(trunc(si));"
"      c.clear;"
"      c.add('SETDATE');"
"      c.add(dt)"
"      r:=cmd('Planisphere_Overlay',c);"
"    end;"
""
"    c.clear;"
"    c.add('REDRAW');"
"    r:=cmd('Planisphere_Overlay',c);"
""
"    c.clear;"
"  end."


[event_0]
s="begin"
""
"  Memo_1.readonly:=true;"
"  Memo_1.Text:='This tool help you make a printed planisphere. Before to start, select the observatory location (with a latitude higher than 20°), the color and the objects you want on the planisphere.';"
""
"  Memo_2.readonly:=true;"
"  Memo_2.Text:='Click the "Set chart" button to create the view for the background map. Be sure to not move the chart position afterward.';"
""
"  Memo_3.readonly:=true;"
"  Memo_3.Text:='Click the "Set overlay" button to create the view for the rotating transparent overlay.';"
""
"  Memo_4.readonly:=true;"
"  Memo_4.Text:='Use the "Print to bitmap" function to save a large image file, open the files in an image editor to make the last adjustment and print.';"
""
"end."

